/*
 * Copyright(C) 2010 Luvina Software Company
 *
 * LoginLogicImpl.java, Oct 29, 2010 ntmhuong
 */
package net.luvina.manageuser.logic.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import net.luvina.manageuser.dto.LoginDto;

import net.luvina.manageuser.logic.LoginLogic;
import net.luvina.manageuser.util.ConfigProperties;
import net.luvina.manageuser.util.Message;

/**
 * LoginLogicImpl
 *
 * @author ntmhuong
 *
 */
@Service("loginLogic")
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false, rollbackFor = { Throwable.class })
public class LoginLogicImpl implements LoginLogic {
	public static final int PASSWORD_ERROR_LOCK_COUNT = 3;
	public static final int PASSWORD_ERROR_LOCK_TIME = 10; // [Min]

	/*
	 * (non-Javadoc)
	 *
	 * @see net.luvina.manageuser.logic.LoginLogic#doLogin(java.lang.String,
	 * java.lang.String)
	 */
	public LoginDto doLogin(String loginId, String password) {
		LoginDto loginDto = new LoginDto();
		if (ConfigProperties.getData("loginId").equals(loginId) && ConfigProperties.getData("password").equals(password)) {
			loginDto.setLoginFlg(true);
			loginDto.setLoginId(loginId);
		} else {
			loginDto.setLoginFlg(false);
			loginDto.setErrMsg(Message.getString("ER011"));

		}
		return loginDto;
	}

}
